function queryCS(){
	var cid = document.getElementById("cid").value;
	// 1.创建异步交互对象
	var xhr = createXmlHttp();
	// 2.设置监听
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4){
			if(xhr.status == 200){
				document.getElementById("csid").innerHTML = xhr.responseText;
			}
		}
	}
	// 3.打开连接
	xhr.open("GET","${pageContext.request.contextPath}/adminProduct_queryCategorySecond.action?time="+new Date().getTime()+"&cid="+cid,true);
	// 4.发送
	xhr.send(null);
	
}

function createXmlHttp(){
	   var xmlHttp;
	   try{ // Firefox, Opera 8.0+, Safari
	        xmlHttp=new XMLHttpRequest();
	    }
	    catch (e){
		   try{// Internet Explorer
		         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		      }
		    catch (e){
		      try{
		         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		      catch (e){}
		      }
	    }

		return xmlHttp;
	 }

function check_add(){
	var pname=document.getElementById("pname").value;
	var marketprice=document.getElementById("market_price").value;
	var shopprice=document.getElementById("shop_price").value;
	var image= document.getElementById("image").value;
	var pdesc=document.getElementById("pdesc").value;
	var cs= document.getElementById("csid").value;
	var storage=document.getElementById("storage").value;
	var keyword=document.getElementById("keyword").value;
	if(pname==null || pname==""){
		alert("商品名不能为空");
		return false;
	} else if(marketprice == null || marketprice ==""){
		alert("市场价不能为空");
		return false;
	} else if(shopprice == null || shopprice ==""){
		alert("商城价不能为空");
		return false;
	} else if(storage==null||storage ==""){
		alert("库存量不能为空")
		return false;
	}else if(keyword==null||keyword==""){
		alert("搜索关键字不能为空")
		return false;
	}else if(cs == null || cs == ""){
		alert("请先选择分类");
		return false;
	}else if(image==null || image ==""){
		alert("图片不能为空");
		return false;
	} else if(pdesc == null || pdesc == ""){
		alert("商品描述不能为空");
		return false;
	}else{
		document.getElementById("productAddForm").submit();				
	}
}

function check_edit(){
	var pname=document.getElementById("pname").value;
	var marketprice=document.getElementById("market_price").value;
	var shopprice=document.getElementById("shop_price").value;
	var image= document.getElementById("image").value;
	var pdesc=document.getElementById("pdesc").value;
	var cs= document.getElementById("csid").value;
	var storage=document.getElementById("storage").value;
	var keyword=document.getElementById("keyword").value;
	if(pname==null || pname==""){
		alert("商品名不能为空");
		return false;
	} else if(marketprice == null || marketprice ==""){
		alert("市场价不能为空");
		return false;
	} else if(shopprice == null || shopprice ==""){
		alert("商城价不能为空");
		return false;
	} else if(storage==null||storage ==""){
		alert("库存量不能为空")
		return false;
	}else if(keyword==null||keyword==""){
		alert("搜索关键字不能为空")
		return false;
	}else if(cs == null || cs == ""){
		alert("请先选择分类");
		return false;
	} else if(pdesc == null || pdesc == ""){
		alert("商品描述不能为空");
		return false;
	}else{
		document.getElementById("productEditForm").submit();				
	}
}